<template>
	<view class="cttit">
		<text>添加子女</text>
		<view class=""></view>
	</view>

	<view class="name">
		<text>父亲姓名</text>
		<text>{{userName}}</text>
<!-- <input type="nickname" @blur="getname" v-model="userInfo.nickName" placeholder="请输入" /> -->
	</view>
	<view class="name">
		<text>性别<text class="xing">*</text></text>
		<up-radio-group v-model="userInfo.sex" placement="row" style="justify-content: flex-end;">
			<up-radio activeColor="#A9070C" label="男" name="男" style="margin-right: 60rpx;"></up-radio>
			<up-radio activeColor="#A9070C" label="女" name="女"></up-radio>
		</up-radio-group>
	</view>
	<view class="name">
		<text>姓氏<text class="xing">*</text> </text>
		<input v-model="userInfo.firstName" placeholder="请输入姓氏" />
	</view>
	<view class="name">
		<text>名字<text class="xing">*</text> </text>
		<input v-model="userInfo.lastName" placeholder="请输入名字" />
	</view>
	<view class="name">
		<text>身份证号<text class="xing">*</text> </text>
		<input v-model="userInfo.idCard" placeholder="请输入身份证号" />
	</view>

	<view class="name">
		<text>排行</text>
		<input v-model="userInfo.rank" placeholder="请输入排行" />
	</view>

	<view class="name3">
		<textarea v-model="userInfo.introduction" placeholder="个人介绍" autoHeight maxlength="-1"></textarea>
	</view>

	<view class="btn">
		<button class="submit" @click="submit">确认提交</button>
	</view>
	<view class="" style="height: 60rpx;"></view>
</template>

<script setup>

	import {
		ref,
		onMounted
	} from 'vue';
	
     import {
		onLoad
	} from '@dcloudio/uni-app';
	
	import { addApply } from "@/api/account.js"
	
	
	
	let userName=ref('')
	let name = ref('')
	let userInfo = ref({
		firstName: '',
		lastName: '',
		idCard: '',
		rank: '',
		sex: '男',
		introduction:''
	})
    onMounted(()=>{
		userName.value=uni.getStorageSync('userInfo').userName
		// userInfo.value=uni.getStorageSync('')
	}) 
	onLoad((e)=>{
		 if(e.type==1){
			   userInfo.value=uni.getStorageSync('luruinfo')
		 }else{
			   uni.removeStorageSync('luruinfo')
		 }
	})
	
	function submit() {
		if(!userInfo.value.firstName){
			uni.showToast({
				title:"请输入姓氏",
				icon:"none"
			}) 
			return
		}
		if(!userInfo.value.lastName){
			uni.showToast({
				title:"请输入姓氏",
				icon:"none"
			}) 
			return
		}
		if(!userInfo.value.idCard){
			uni.showToast({
				title:"请输入身份证号",
				icon:"none"
			}) 
			return
		}
		
		
		uni.showLoading({
			mask: true,
			title: "提交中..."
		})
		
		addApply(userInfo.value).then(res => {
			uni.hideLoading()
			uni.switchTab({
				url: "/pages/mine/index"
			})
		})


	}


</script>

<style lang="scss" scoped>
	.xing {
		color: #A9070C !important;
	}

	.name3 {
		width: 670rpx;
		margin-left: 40rpx;

		textarea {
			border-radius: 16rpx;
			width: 670rpx;
			height: auto;
			box-sizing: border-box;
			padding: 30rpx;
			font-size: 28rpx;
			background: #fff !important;
			min-height: 160rpx;
		}
	}



	.cttit {
		margin-top: 36rpx;
		margin-left: 56rpx;
		position: relative;
		display: flex;
		flex-direction: column;

		&>text {
			font-family: PingFang-SC, PingFang-SC;
			font-weight: bold;
			font-size: 32rpx;
			color: #111111;
			line-height: 24rpx;
			position: relative;
			z-index: 10;
		}

		view {
			width: 130rpx;
			height: 16rpx;
			border-radius: 20rpx;
			background: #C7A46F;
			position: absolute;
			bottom: -6rpx;
		}
	}

	.btn {
		margin-top: 40rpx;
		width: 670rpx;
		margin-left: 40rpx;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		height: 88rpx;

		.submit {
			width: 670rpx;
			border-radius: 44rpx 44rpx 44rpx 44rpx;
			height: 88rpx;
			background: #C7A46F;
			display: flex;
			align-items: center;
			justify-content: center;
			font-family: PingFang-SC, PingFang-SC;
			font-weight: bold;
			font-size: 36rpx;
			color: #FFFFFF;
		}
	}


	button::after {
		border: none;
	}

	.name {
		width: 670rpx;
		height: 100rpx;
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		margin: 24rpx 40rpx;
		display: flex;
		align-items: center;
		box-sizing: border-box;
		padding: 0 30rpx;
		justify-content: space-between;

		text {
			font-family: PingFang-SC, PingFang-SC;
			font-weight: bold;
			font-size: 30rpx;
			color: #111111;
		}

		input {
			text-align: right;
			font-size: 30rpx;
			margin-left: 30rpx;
		}
	}
</style>